<template>
  <div class="song-list">
    <ul>
      <li v-for="(item, index) in songs" class="item" :key="index" @click="getUrl(item.url)">
        <div class="content">
          <h2 class="name">{{item.name}}</h2>
          <p class="desc">{{getDesc(item)}}</p>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>

export default {
  name: 'song-list',
  props: {
    songs: {
      type: Array,
      default: null
    }
  },
  methods: {
    getDesc(item) {
      return `${item.singer} - ${item.album}`
    },
    getUrl (url) {
      console.log(url)
    }
  }
}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
  @import "~common/stylus/variable"
  @import "~common/stylus/mixin"

  .song-list .item {
    display: -ms-flexbox;
    display: flex;
    -ms-flex-align: center;
    align-items: center;
    box-sizing: border-box;
    height: 64px;
    font-size: 14px;
  }
  .song-list .item .content {
    flex: 1;
    line-height: 20px;
    overflow: hidden;
  }
  .song-list .item .content .name {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    color: #fff;
  }
  .song-list .item .content .desc {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    margin-top: 4px;
    color: hsla(0,0%,100%,.3);
  }
</style>
